#! usr/bin/env python
# -*- coding: utf-8 -*-

import shutil
import urllib.error
import string
import time
import os
import urllib.request
import urllib.parse
from bs4 import BeautifulSoup
from selenium import webdriver
import datetime
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import sys
import selenium.webdriver.support.ui as ui
import socket
import selenium.webdriver.phantomjs
from pathlib import Path


loginurl = 'http://1.1.1.3/ac_portal/default/pc.html?template=default&tabs=pwd&vlanid=0&url=http://www.google.com.hk%2furl%3fsa%3dp%26hl%3dzh-CN%26pref%3dhkredirect%26pval%3dyes%26q%3dhttp%3a%2f%2fwww.google.com.hk%2f%253Fgws_rd%253Dcr%26ust%3d1522714939423953%26usg%3dAOvVaw0ZRSKiPxb9cm76Nv34qGbt'
user = 'zha.daolong'
pwd = 'zhadaolong*3'

def main():
    while(1):
        driver = webdriver.Chrome('C:/Tools/chromedriver.exe')
        driver.get(loginurl)
        username = driver.find_element_by_xpath('//*[@id="password_name"]')
        username.send_keys(user)
        password = driver.find_element_by_xpath('//*[@id="password_pwd"]')
        password.send_keys(pwd)
        submit = driver.find_element_by_xpath('//*[@id="password_submitBtn"]')
        time.sleep(2)
        submit.click()
        time.sleep(2)
        driver.close()
        time.sleep(600)



if __name__ == 'main':
    main()
else:
    main()


